package com.tanhua.api.impl.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.api.db.BlackListApi;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.mapper.db.BlackListMapper;
import com.tanhua.mapper.db.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

//黑名单
@Service
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private BlackListMapper blackListMapper;

    @Override //分页查询
    public IPage<UserInfo> findBlackList(Integer page, Integer pagesize, Long userId) {
         //使用mybatisplus的分页插件
        Page pg = new Page(page,pagesize);
        IPage<UserInfo> iPage=userInfoMapper.findBlackList(pg,userId);
        return iPage;
    }

    @Override
    public void deleteBlackById(Integer blackId, Long userId) {
        QueryWrapper qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        qw.eq("black_user_id",blackId);
        blackListMapper.delete(qw);
    }
}
